/******************************************************************************
   Copyright (c) 2006 by RockOS.
   All rights reserved.

   This software is supported by Rock Software Workroom.

   Any bugs please contact the author with e-mail or QQ:
   E-mail : baobaoba520@yahoo.com.cn
       QQ : 59681888
*******************************************************************************
File name   : 44b_lib.h
Description : This is the hardware management libary for QW44B0x board, the CPU
            : is ARM S3C44B0x, you should write a new hwlib.h when you are
            : porting RockOS to other board.
            : 
Auther      : sunxinqiu
History     :
  2006-3-15   first release.
******************************************************************************/
#ifndef __44B_LIB_H__
#define __44B_LIB_H__

#ifdef __cplusplus
extern "C" {
#endif

/*****************************************************************************
 * Macro constant MCLK MUST keep consist with the system MCLK frequency. The
 * Fin, Fout and M_DIV, P_DIV, S_DIV are defined in file 44b.inc
 *****************************************************************************/
#define MCLK            32000000
#define TICK_INT_FREQ   100

#define BAUD_DEFAULT    115200

#define Non_Cache_Start	((unsigned)0x2000000)
#define Non_Cache_End 	((unsigned)0xc000000)


/* UART options */
enum
{
    UART_CH0,
    UART_CH1
};
enum
{
    PARITY_NONE = 0,
    PARITY_ODD  = 4,
    PARITY_EVEN = 5,
    PARITY_MARK = 6,
    PARITY_CLR  = 7
};

/* LEDs' identifies. */
enum
{
    LED1    = 1,
    LED2	= 2,
    LED3	= 3,
    LED_ALL = 4
};

enum
{
    LED_OFF = 0,
    LED_ON  = 1
};

/* PWM timer's identifies. */
enum
{
    PWM_TIMER0 = 0,
    PWM_TIMER1 = 1,
    PWM_TIMER2 = 2,
    PWM_TIMER3 = 3,
    PWM_TIMER4 = 4,
    PWM_TIMER5 = 5
};

void init_gpio (void);
void light_led (int led, int action);

void init_pwm (void);
void pwm_start (int which, int tout, int periodly);
void pwm_stop(int which);

void init_uart(void);
void UART_sendChar(int which, char ch);
void UART_sendString(int which, const char * pszstring);

void init_irq(void);
void enable_irq(void);
void disable_irq(void);

void flash_led(void);
void delay(unsigned n);

#ifdef __cplusplus
}
#endif

#endif
